<template>
  <div>
    <el-link
      v-if="!Array.isArray(file)"
      type="primary"
      :href="file.oss_path"
      :download="file.filename"
      @click.native.prevent="handleDownload(file.oss_path)"
    >
      <svg-icon icon-class="downloadicon" />
      <VText :value="file.filename" :line="2" class="v-text-color" />
    </el-link>
    <template v-else>
      <div v-for="item in file" :key="item">
        <el-link
          :href="item.oss_path"
          type="primary"
          :download="item.filename"
          @click.native.prevent="handleDownload(item.oss_path)"
        >
          <svg-icon icon-class="downloadicon" />
          <VText :value="item.source_name" class="v-text-color" />
        </el-link>
      </div>
    </template>
  </div>
</template>

<script setup>
import { handleLink } from "@/hooks/tool.js";
const props = defineProps({
  file: {
    type: [Object, Array],
    default: () => {
      return [];
    },
  },
});
// const file = ref([]);
const file = computed(() => props.file);
const handleDownload = (val) => {
  handleLink(val);
};
</script>

<style scoped lang="scss">
:deep(.v-text-color) {
  .v-text-content {
    color: #3486fe;
  }
}
</style>
